package com.cskaoyan.controller.set;

import com.cskaoyan.bean.bo.configbo.MallConfigBo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.vo.set.ExpressConfigVo;
import com.cskaoyan.bean.vo.set.OrderConfigVo;
import com.cskaoyan.bean.vo.set.WxConfigVo;
import com.cskaoyan.service.set.AdminConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:todo 用于配置管理的controller
 * @Author:todo wang xv
 * @Date:todo 2022/11/21
 */
@RestController
@RequestMapping("admin/config/")
public class AdminConfigController {
    @Autowired
    AdminConfigService adminConfigService;

    /**
     * @Description:todo 商场配置回显
     * @Author:todo wang xv
     * @Date:todo 2022/11/21
     */
    @GetMapping("mall")
    public BaseRespVo GetMall() {
        MallConfigBo mallConfigBo = adminConfigService.mallConfigShow();
        return BaseRespVo.succeed(mallConfigBo);
    }

    /**
     * @Description:todo 用来处理如果要修改的情况 POST
     * @Author:todo wang xv
     * @Date:todo 2022/11/21
     */
    @PostMapping("mall")
    public BaseRespVo postMall(@RequestBody MallConfigBo mallConfigBo) {
        adminConfigService.mallConfig(mallConfigBo);
        return BaseRespVo.succeed();
    }

    /**
     * @Description:todo 运费配置时显示
     * @Author:todo wang xv
     * @Date:todo 2022/11/21
     */
    @GetMapping("express")
    public BaseRespVo getExpress() {
        ExpressConfigVo expressConfigVo = adminConfigService.expressConfigShow();
        return BaseRespVo.succeed(expressConfigVo);
    }

    /**
     * @Description:todo 运费配置的修改
     * @Author:todo wang xv
     * @Date:todo 2022/11/21
     */
    @PostMapping("express")
    public BaseRespVo postExpress(@RequestBody ExpressConfigVo expressConfigVo) {
        adminConfigService.expressConfig(expressConfigVo);
        return BaseRespVo.succeed();
    }

    /**
     * @Description:todo 订单配置的显示
     * @Author:todo wang xv
     * @Date:todo 2022/11/21
     */
    @GetMapping("order")
    public BaseRespVo getOrder() {
        OrderConfigVo orderConfigVo = adminConfigService.orderConfigShow();
        return BaseRespVo.succeed(orderConfigVo);
    }

    /**
     * @Description:todo 订单配置的修改
     * @Author:todo wang xv
     * @Date:todo 2022/11/21
     */
    @PostMapping("order")
    public BaseRespVo postOrder(@RequestBody OrderConfigVo orderConfigVo) {
        adminConfigService.orderConfig(orderConfigVo);
        return BaseRespVo.succeed();
    }

    /**
     * @Description:todo 对小程序配置的显示
     * @Author:todo wang xv
     * @Date:todo 2022/11/21
     */
    @GetMapping("wx")
    public BaseRespVo getWx() {
        WxConfigVo wxConfigVo = adminConfigService.wxConfigShow();
        return BaseRespVo.succeed(wxConfigVo);
    }

    /**
     * @Description:todo 小程序配置的修改
     * @Author:todo wang xv
     * @Date:todo 2022/11/21
     */
    @PostMapping("wx")
    public BaseRespVo postWx(@RequestBody WxConfigVo wxConfigVo) {
        adminConfigService.wxConfig(wxConfigVo);
        return BaseRespVo.succeed();
    }
}
